/**
 * 
 */
package edu.zut.hb.software.sample.base.domain;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;



/**
 * @author clown
 *
 */
public class BaseEntity<PK extends Serializable> extends AbstractEntity{
	/**
	 * 
	 */
	private static final long serialVersionUID = -4028536152637147089L;
	/*
	 * create entity date
	 */
	protected Date dateCreated = new Date();
	/*
	 * Whether the entity was modified
	 */
	protected Date dateModified = new Date();
	/*
	 * Whether the entity was deleted
	 */
	protected Boolean dateDeleted;
	
	protected String entityName;
	
	protected PK id;
	

	public String getEntityName() {
		return entityName;
	}

	public void setEntityName(String entityName) {
		this.entityName = entityName;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public Date getDateModified() {
		return dateModified;
	}

	public void setDateModified(Date dateModified) {
		this.dateModified = dateModified;
	}

	public Boolean getDateDeleted() {
		return dateDeleted;
	}

	public void setDateDeleted(Boolean dateDeleted) {
		this.dateDeleted = dateDeleted;
	}

	public PK getId() {
		return id;
	}

	public void setId(PK id) {
		this.id = id;
	}

	
	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this.id);
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
	}

	@Override
	public boolean equals(Object obj) {
		if (null != obj) {
			if (obj instanceof BaseEntity) {
				@SuppressWarnings("unchecked")
				BaseEntity<PK> domain =  (BaseEntity<PK>) obj;
				if (this.id == domain.id) {
					return true;
				}
			}
		}
		return false;

}}
